From 0eb10a9560e43ad43f5e5c4e0569c8fa64aa80e1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 18 Jul 2019 14:42:14 +0200 Subject: [PATCH] phase2: implement work dir sharing Signed-off-by: Jo-Philipp Wich --- phase1/master.cfg | 2 +- phase2/master.cfg | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index d9ca8d8..a91864a 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -471,7 +471,7 @@ for target in targets: factory.addStep(ShellCommand( name = "sharedwd", description = "Setting up shared work directory", - command = 'test -L "$PWD" || (mkdir -p "../shared-workdir" && rm -rf "$PWD" && ln -s shared-workdir "$PWD")', + command = 'test -L "$PWD" || (mkdir -p ../shared-workdir && rm -rf "$PWD" && ln -s shared-workdir "$PWD")', workdir = ".", haltOnFailure = True, doStepIf = IsSharedWorkdir)) diff --git a/phase2/master.cfg b/phase2/master.cfg index ed09c8b..6b8214b 100644 --- a/phase2/master.cfg +++ b/phase2/master.cfg @@ -64,10 +64,21 @@ for section in ini.sections(): ini.has_option(section, "phase") and ini.getint(section, "phase") == 2: name = ini.get(section, "name") password = ini.get(section, "password") + sl_props = { 'shared_wd': False } max_builds[name] = 1 + if ini.has_option(section, "builds"): max_builds[name] = ini.getint(section, "builds") - c['slaves'].append(BuildSlave(name, password, max_builds = max_builds[name])) + + if max_builds[name] == 1: + sl_props['shared_wd'] = True + + if ini.has_option(section, "shared_wd"): + sl_props['shared_wd'] = ini.getboolean(section, "shared_wd") + if sl_props['shared_wd'] and (max_builds != 1): + raise ValueError('max_builds must be 1 with shared workdir!') + + c['slaves'].append(BuildSlave(name, password, max_builds = max_builds[name], properties = sl_props)) # 'slavePortnum' defines the TCP port to listen on for connections from slaves. # This must match the value configured into the buildslaves (with their @@ -244,6 +255,9 @@ def UsignSec2Pub(seckey, comment="untrusted comment: secret key"): return "{}\n{}".format(re.sub(r"\bsecret key$", "public key", comment), base64.b64encode(seckey[0:2] + seckey[32:40] + seckey[72:])) +def IsSharedWorkdir(step): + return bool(step.getProperty("shared_wd")) + c['builders'] = [] @@ -259,6 +273,15 @@ for arch in arches: factory = BuildFactory() + # setup shared work directory if required + factory.addStep(ShellCommand( + name = "sharedwd", + description = "Setting up shared work directory", + command = 'test -L "$PWD" || (mkdir -p ../shared-workdir && rm -rf "$PWD" && ln -s shared-workdir "$PWD")', + workdir = ".", + haltOnFailure = True, + doStepIf = IsSharedWorkdir)) + # find number of cores factory.addStep(SetProperty( name = "nproc", -- 2.30.2